file(STRINGS ${CMAKE_SOURCE_DIR}/VERSION VERSION_STR)
string(STRIP ${VERSION_STR} VERSION_STR)
set(ZUC_PACKAGE_VERSION "${VERSION_STR}")
string (REGEX REPLACE "[\n\t\r]" "" VERSION_STR ${VERSION_STR})
string (REGEX REPLACE "_*[a-zA-Z]" "" VERSION_STR_DEB ${VERSION_STR})
string (REGEX REPLACE "_" "." VERSION_STR_DEB ${VERSION_STR_DEB})

#编译架构
execute_process(
	COMMAND	dpkg --print-architecture
	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 
	OUTPUT_VARIABLE BUILD_ARCH
)
string (REGEX REPLACE "[\n\t\r]" "" BUILD_ARCH ${BUILD_ARCH})

#编译时间
string(TIMESTAMP COMPILE_TIME %Y%m%d)
string(TIMESTAMP COMPILE_TIME2 %Y%m%d_%H%M%S)


message("JKZUC build version: ${VERSION_STR}-${COMPILE_TIME2}-${BUILD_ARCH}_${CMAKE_BUILD_TYPE}")

#git信息
execute_process(
	COMMAND	git log -1 --format=%H
	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 
	OUTPUT_VARIABLE GIT_VERSION
)
string (REGEX REPLACE "[\n\t\r]" "" GIT_VERSION ${GIT_VERSION})

# 预设路径信息
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
	set(DEFULAT_ROOT_DIR "${JKZUC_ROOT_DIR}")
	# set(DEFULAT_ROOT_DIR "/usr/etc/jkzuc")
	set(DEFAULT_USER_BIN_DIR "${DEFULAT_ROOT_DIR}/Debug/bin")
else()
	set(DEFULAT_ROOT_DIR "/usr/etc/jkzuc")
	set(DEFAULT_USER_BIN_DIR "${DEFULAT_ROOT_DIR}/bin")
endif()
set(USER_CONFIG_DIR "${DEFULAT_ROOT_DIR}/configs/JAKA")
set(DEFAULT_LOG_DIR "${DEFULAT_ROOT_DIR}/scripts/log")
set(DEFAULT_DIAGNOSIS_DIR "${DEFULAT_ROOT_DIR}/scripts/log/diagnosis")
set(DEFAULT_PROGRAM_DIR "${DEFULAT_ROOT_DIR}/scripts/program")

# 配置信息转换
configure_file(
    "${JKZUC_ROOT_DIR}/src/config.h.in"
    "${JKZUC_ROOT_DIR}/src/config.h"
)
configure_file(
    "${JKZUC_ROOT_DIR}/src/JKZUC_INFO.in"
    "${JKZUC_ROOT_DIR}/package/deb/usr/etc/jkzuc/JKZUC_INFO.ini"
)
configure_file(
    "${JKZUC_ROOT_DIR}/package/control.in"
    "${JKZUC_ROOT_DIR}/package/deb/DEBIAN/control"
)